//
//  AddPayDepositApi.m
//  EMMApp
//
//  Created by YangLiang on 16/5/26.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "AddPayDepositApi.h"
#define myUrlMethod @"addPayDeposit"
#define myUrlPath @"/appapi/addPayDeposit"

@implementation AddPayDepositApi
{
    NSString *_body;
}
- (instancetype)initWithCustomerId:(NSString *)customerId
                      isPayDeposit:(NSString *)isPayDeposit
                            roomId:(NSString *)roomId
                     calculateArea:(NSString *)calculateArea
                     discountPrice:(NSString *)discountPrice
                discountTotalPrice:(NSString *)discountTotalPrice
                    payDepositCode:(NSString *)payDepositCode
                   payDepositMoney:(NSString *)payDepositMoney
                           agentId:(NSString *)agentId
                    payDepositDate:(NSString *)payDepositDate
                            remark:(NSString *)remark
                       auditStatus:(NSString *)auditStatus
                        memberName:(NSString *)memberName
                      documentType:(NSString *)documentType
                    documentNumber:(NSString *)documentNumber
                            mobile:(NSString *)mobile
                          mailPost:(NSString *)mailPost
                          postcode:(NSString *)postcode
                              type:(NSString *)type
                          category:(NSString *)category
                customerFamilyList:(NSArray *)customerFamilyList
                         imageList:(NSMutableArray *)imageList {
    
    self = [super init];
    if (self) {
        NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
        NSString *merchantId = [userdf objectForKey:@"merchantId"];
        NSString *userId = [userdf objectForKey:@"userNameId"];
        NSString *token = [userdf objectForKey:@"is_login"];
        NSString *projectCode = [userdf objectForKey:@"projectCode"];
        
        NSMutableDictionary *params = [NSMutableDictionary dictionary];
        [params setValue:apiVersion forKey:@"version"];
        [params setValue:[IDTools devId2] forKey:@"terminalCode"];
        [params setValue:merchantId forKey:@"merchantId"];
        [params setValue:userId forKey:@"userId"];
        [params setValue:token forKey:@"token"];
        [params setValue:projectCode forKey:@"projectCode"];
        [params setValue:customerId forKey:@"customerId"];
        [params setValue:isPayDeposit forKey:@"isPayDeposit"];
        [params setValue:roomId forKey:@"roomId"];
        [params setValue:calculateArea forKey:@"calculateArea"];
        [params setValue:discountPrice forKey:@"discountPrice"];
        [params setValue:discountTotalPrice forKey:@"discountTotalPrice"];
        [params setValue:payDepositCode forKey:@"payDepositCode"];
        [params setValue:payDepositMoney forKey:@"payDepositMoney"];
        [params setValue:agentId forKey:@"agentId"];
        [params setValue:payDepositDate forKey:@"payDepositDate"];
        [params setValue:remark forKey:@"remark"];
        [params setValue:auditStatus forKey:@"auditStatus"];
        [params setValue:memberName forKey:@"memberName"];
        [params setValue:documentType forKey:@"documentType"];
        [params setValue:documentNumber forKey:@"documentNumber"];
        [params setValue:mobile forKey:@"mobile"];
        [params setValue:mailPost forKey:@"mailPost"];
        [params setValue:postcode forKey:@"postcode"];
        [params setValue:type forKey:@"type"];
        [params setValue:category forKey:@"category"];
        [params setValue:customerFamilyList forKey:@"customerFamilyList"];
        [params setValue:imageList forKey:@"imageList"];

        _body = [@{@"params" : params} JSONString];
        NSLog(@"%@:\n %@%@?body=%@", myUrlMethod, apiBaseUrl, myUrlPath, _body);
    }
    return self;
}

#pragma mark - 父类继承拓展

- (NSString *)requestUrl
{
    return myUrlPath;
}

- (id)requestArgument
{
    return @{ @"body" : _body };
}

- (NSString *)methodString
{
    return myUrlMethod;
}


#pragma mark - 通用

- (AddPayDeposit *)resultData
{
    id myObj = [IDTools jsonStrToObjc:self.responseString method:myUrlMethod];
    
    AddPayDeposit *data = (AddPayDeposit *)myObj;
    
    NSLog(@"%@ resultData is %@", myUrlMethod, data);
    
    return data;
}

- (BOOL)isSuccess
{
    NSString *str = [[self resultData] result];
    if ([NSString isStringEmpty:str] || ![str isEqualToString:@"1"]) {
        return NO;
    } else {
        return YES;
    }
}
@end
